package com.acme.bankapp.service.bank;

import java.util.List;

import com.acme.bankapp.domine.bank.*;

public class BankService {

    public static Bank createNewBank() {
        return new Bank();
    }

    public static Bank createNewBank(final List<ClientRegistrationListener>
        clientRegistrationListenerList) {
        return new Bank(clientRegistrationListenerList);
    }

    public static void addClient(final Bank bank, final Client client) {
        bank.addClient(client);
    }

    public static Client addClient(final Bank bank, final String name,
        final Gender gender) {
        Client client = new Client(name, gender);
        bank.addClient(client);
        return client;
    }

    public static void printBalance(final Bank bank) {
        System.out.println("printBalance");
        for (int i = 0; i < bank.getCountClients(); i++) {
            Client client = bank.getClients()[i];
            for (int j = 0; j < client.getCountAccount(); j++) {
                Account account = client.getAccounts()[j];
                System.out.println(client.getClientSalutation()
                        + " : " + account.getBalance());
            }
        }
    }

    public static void printMaximumAmountToWithdraw(final Bank bank) {
        System.out.println("printMaximumAmountToWithdraw");
        for (int i = 0; i < bank.getCountClients(); i++) {
            Client client = bank.getClients()[i];
            for (int j = 0; j < client.getCountAccount(); j++) {
                Account account = client.getAccounts()[j];
                System.out.println(client.getClientSalutation() + " : "
                                   + account.maximumAmountToWithdraw());
            }
        }

    }
}
